package com.lzj.firewallmamager.service.impl;

import com.github.pagehelper.PageHelper;
import com.lzj.firewallmamager.entity.FirewallPolicyEntity;
import com.lzj.firewallmamager.mapper.FirewallMapper;
import com.lzj.firewallmamager.service.FirewallService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FirewallServiceImpl implements FirewallService {

    @Autowired
    private FirewallMapper firewallMapper;

    @Override
    public void insertPolicy(FirewallPolicyEntity entity) throws Exception {
        firewallMapper.insert(entity);
    }

    @Override
    public FirewallPolicyEntity getPolicyById(int id) throws Exception {
        return firewallMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<FirewallPolicyEntity> getAllPolicy(int pageNum, int pageSize) {
        //分页
        PageHelper.startPage(pageNum,pageSize);
        return firewallMapper.selectAll();
    }
}
